/**
 *    Copyright 2009-2015 the original author or authors.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package org.apache.ibatis.reflection.wrapper;

import java.util.List;

import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.factory.ObjectFactory;
import org.apache.ibatis.reflection.property.PropertyTokenizer;

/**
 * MetaObject对象的包装类接口
 * 直接实现有：
 * 1、{@link BaseWrapper},包装类接口抽象实现类,具体的实现子类有：{@link BeanWrapper}和{@link MapWrapper}
 * 2、{@link CollectionWrapper},集合类型对象的包装实现类
 * @author Clinton Begin
 */
public interface ObjectWrapper {
	/**
	 * 获取属性对应的值
	 * @param prop
	 * @return
	 */
  Object get(PropertyTokenizer prop);
  /**
   * 设置属性对应的值
   * @param prop
   * @param value
   */
  void set(PropertyTokenizer prop, Object value);
  /**
   * 处理复杂的属性字段,返回的数据格式：属性名.子属性名.子属性名……，也可能是null
   * @param name
   * @param useCamelCaseMapping
   * @return
   */
  String findProperty(String name, boolean useCamelCaseMapping);
  /**
   * 获取对象的所有get属性的名称
   * @return
   */
  String[] getGetterNames();
  /**
   * 获取对象的所有set属性的名称
   * @return
   */
  String[] getSetterNames();
  /**
   * 获取set属性名对应的类型(参数类型)
   * @param name
   * @return
   */
  Class<?> getSetterType(String name);
  /**
   * 获取get属性名对应的类型（返回类型）
   * @param name
   * @return
   */
  Class<?> getGetterType(String name);
  /**
   * 判断类中是否包含属性名对应的set属性
   * @param name
   * @return
   */
  boolean hasSetter(String name);
  /**
   * 判断类中是否包含属性名对应的get属性
   * @param name
   * @return
   */
  boolean hasGetter(String name);
  /**
   * 初始化MetaObject对象
   * @param name
   * @param prop
   * @param objectFactory
   * @return
   */
  MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop, ObjectFactory objectFactory);
  /**
   * 判断是否是集合类型
   * @return
   */
  boolean isCollection();
  /**
   * 集合类型，添加元素
   * @param element
   */
  void add(Object element);
  /**
   * 集合类型，批量添加元素
   * @param element
   */
  <E> void addAll(List<E> element);

}
